package com.test.burnincash.dialog_burnin;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.ListView;

import androidx.annotation.NonNull;

import com.test.burnincash.R;
import com.test.burnincash.adapter_burnin.CustomerServiceListAdapter_burnin;

public class CustomerServiceDialog_burnin extends Dialog {

    public CustomerServiceDialog_burnin(@NonNull Context context) {
        super(context);
    }

    private int listHeight = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_customer_service_burnin);
        getWindow().setBackgroundDrawableResource(R.color.trans);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        setCanceledOnTouchOutside(false);
        initView();
    }

    @SuppressLint("SetTextI18n")
    private void initView(){

        findViewById(R.id.dialog_customer_service_ib_back).setOnClickListener(v -> dismiss());

        ListView listView = findViewById(R.id.dialog_customer_service_lv_list);
        CustomerServiceListAdapter_burnin customerServiceListAdapter = new CustomerServiceListAdapter_burnin(getContext());
        listView.setAdapter(customerServiceListAdapter);

        ViewGroup.LayoutParams layoutParams = listView.getLayoutParams();
        if (listHeight ==0) listHeight = layoutParams.height;
        layoutParams.height = customerServiceListAdapter.getCount()* listHeight;
        listView.setLayoutParams(layoutParams);

    }
}
